import QtQuick 2.12
import QtQuick.Window 2.12

Item {
    id: inputPanel
    readonly property bool __isRootItem: inputPanel.parent != null && inputPanel.parent.parent == null
    property var name: "haha"
    implicitHeight: flw.height
    MouseArea {
            z: -1
            anchors.fill: keyboard
            enabled: true
    }
    Binding {
        target: inputPanel
        property: "keyboardRect"
        value: mapToItem(null, __isRootItem ?flw.x:x + (inputPanel.x>0?0:0),
                               __isRootItem ?flw.y:y + (inputPanel.x>0?0:0),
                               flw.width + (inputPanel.width>0?0:0),
                               flw.height + (inputPanel.height>0?0:0))
    }


    property rect keyboardRect  //signal keyboardRectChanged()
    Component.onCompleted: setFLWGeometry()
    onWidthChanged: setFLWGeometry()
    onHeightChanged: setFLWGeometry()
    function setFLWGeometry() {
        flw.width = Math.min(height*16/15, width)
        flw.height = flw.width*5/16;
        flw.x = (width-flw.width)/2
        //anchors.horizontalCenter: parent.horizontalCenter #error
        //anchors.bottom: parent.bottom #error
        flw.y =  height-flw.height
    }
    FramelessWindow {
        id: flw
        Text {
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.top: parent.top
            height: 40
            text: "Testing"
        }
        Rectangle {
            anchors.fill: parent
            color: "red"
            id: keyboard
            Component.onCompleted: {

            }
            MouseArea {
                id: child
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                    //cursorShape = Qt.PointingHandCursor;
                    parent.color = "blue";
                }
                onExited: {
                    cursorShape = Qt.ArrowCursor;
                    parent.color = "red";
                }
                onPressed: parent.color = "yellow";
                onReleased: parent.color = "blue";
            }
        }

    }

}
